package cn.guozeyiblog.client;

import java.util.List;

import cn.guozeyiblog.blogutils.Category;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CategoryAdapter extends BaseAdapter{
	
	private List<Category> listdata;
	private Context context;
	private LayoutInflater inflater;
	public CategoryAdapter(List<Category> listdata,Context context) {
		// TODO Auto-generated constructor stub
		this.listdata = listdata;
		this.context = context;
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listdata.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listdata.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layout = null;
		if (convertView==null) {
			layout = (LinearLayout) inflater.inflate(R.layout.category_item, null);
		}else {
			layout = (LinearLayout) convertView;
		}
		 
		((TextView)layout.findViewById(R.id.cate_text)).setText(listdata.get(position).getCategroyName());
		return layout;
	}

}
